// 云函数入口文件
const cloud = require('wx-server-sdk')
const axios = require('axios');

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  let buffer=null;
  // 下载CDN图片进行检查
  await axios({
    method: 'get',
    url: event.imgcontent,
    responseType: 'arraybuffer'
  }).then(res => {
    buffer=res.data;
  })
  try {
    //调用imgSecCheck接口
    return await cloud.openapi.security.imgSecCheck({
      media:{
        //按照要求填写属性参数       
        contentType: 'image/png',
        value: buffer
      }
    })    
  } catch (error) {
    return error
  }
}